﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DAL;
using Microsoft.Practices.Unity;
using TripAssistantDesktop.View;
using TripAssistantDesktop.ViewModel;

namespace TripAssistantDesktop
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private IUnityContainer _container; 
        public static readonly DependencyProperty SelectedTripProperty = DependencyProperty.Register("SelectedTrip",
                                                                                                   typeof(Trip),
                                                                                                   typeof(MainWindow));

        public Trip SelectedTrip
        {
            get { return (Trip) GetValue(SelectedTripProperty); }
            set { SetValue(SelectedTripProperty, value);}
        }
  
        public MainWindow(IUnityContainer container)
        {
            InitializeComponent();
            DataContext = container.Resolve<IMainWindowViewModel>();
            Loaded += OnWindoLoaded;
            _container = container; 
        }

        private void OnWindoLoaded(object sender, RoutedEventArgs e)
        {
            Login loginForm = _container.Resolve<Login>(); 
            loginForm.ShowDialog();
        }
    }
}
